import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [{
        path: '/login',
        component: () =>
            import ('@/views/login/index'),
        hidden: true
    },

    {
        path: '/404',
        component: () =>
            import ('@/views/404'),
        hidden: true
    },

    {
        path: '/',
        component: Layout,
        redirect: '/dashboard',
        children: [{
            path: 'dashboard',
            name: 'Dashboard',
            component: () =>
                import ('@/pages/dashboard/index'),
            meta: { title: '首页大屏(陈益嘉)', icon: '01' }
        }]
    },
    {
        path: '/czh',
        component: Layout,
        children: [{
            path: 'index',
            name: 'czh_index',
            component: () =>
                import ('@/pages/czh/index'),
            meta: { title: '疫情动态(蔡子豪)', icon: '02' }
        }]
    },

    {
        path: '/zxm',
        component: Layout,
        children: [{
            path: 'demo01',
            name: 'zxm_demo01',
            component: () =>
                import ('@/pages/zxm/demo01'),
            meta: { title: '疫情图表(赵新明)', icon: '03' }
        }]
    },


    {
        path: '/cms',
        component: Layout,
        children: [{
                path: 'article',
                name: 'cms_article',
                component: () =>
                    import ('@/pages/cms/article'), //@代表src
                meta: { title: '疫情资讯(赵新明)', icon: '04' }
            },

            {
                path: 'article_create',
                name: 'cms_article_create',
                hidden: true, //设置true,这个项目不会出现在左侧条目当中
                component: () =>
                    import ('@/pages/cms/articleCreate'), //@代表src
                meta: { title: '疫情资讯发布', icon: '05' }
            }

        ]
    },




    {
        path: '/news',
        component: Layout,
        children: [{
            path: 'new',
            name: 'new_new',
            component: () =>
                import ('@/pages/news/new'),
            meta: { title: '新闻资讯(王灯峰)', icon: '07' }
        }]
    },




    // 定点医院
    {
        path: '/hospital',
        component: Layout,
        children: [{
                path: 'index',
                name: 'hospital_index',
                component: () =>
                    import ('@/pages/hospital/index'),
                meta: { title: '定点医院(夏世杰)', icon: '08' }
            },
            {
                path: 'create',
                name: 'hospital_create',
                hidden: true,
                component: () =>
                    import ('@/pages/hospital/Create'),
            },
            {
                path: 'location',
                name: 'hospital_location',
                hidden: true,
                component: () =>
                    import ('@/pages/hospital/Location'),
            }
        ]
    },




    {
        path: '/huxiaojian',
        component: Layout,
        children: [{
            path: 'index',
            name: 'huxiaojian_index',
            component: () =>
                import ('@/pages/huxiaojian/index'),
            meta: { title: '用户管理(胡晓建)', icon: '09' }
        }]
    },


    {
        path: '/yk_index',
        component: Layout,
        children: [{
            path: 'index',
            name: 'yk_index',
            component: () =>
                import ('@/pages/yk/index'),
            meta: { title: '数据统计(杨凯)', icon: '10' }
        }]
    },

    {
        path: '/yk_map',
        component: Layout,
        children: [{
            path: 'map',
            name: 'yk_map',
            component: () =>
                import ('@/pages/yk/map'),
            meta: { title: '疫情地图(杨凯)', icon: '11' }
        }]
    },

    {
        path: '/wangwei',
        component: Layout,
        children: [{
            path: 'index',
            name: 'wangwei_index',
            component: () =>
                import ('@/pages/wangwei/index'),
            meta: { title: '疫情表格(王伟)', icon: '12' }
        }]
    },

    {
        path: '/xak',
        component: Layout,
        children: [{
            path: 'index',
            name: 'xak_index',
            component: () =>
                import ('@/pages/xak/index'),
            meta: { title: '疫情折线图(解安康)', icon: '13' }
        }]
    },



    {
        path: '/wdf',
        component: Layout,
        children: [{
            path: 'index',
            name: 'wdf_index',
            component: () =>
                import ('@/pages/wdf/index'),
            meta: { title: '疫情折线图(王灯峰)', icon: '01' }
        }]
    },


    // 疫情数据
    {
        path: '/data',
        component: Layout,
        meta: { title: '疫情数据(陈益嘉)', icon: '02' },
        children: [{
                path: 'list',
                component: () =>
                    import ('@/pages/data/List'),
                meta: { title: '疫情列表', icon: '03' }
            },
            {
                path: 'input',
                component: () =>
                    import ('@/pages/data/Input'),
                meta: { title: '疫情输入', icon: '04' }
            }
        ]
    },




    {
        path: '/cyj.xz',
        component: Layout,
        children: [{
            path: 'index',
            name: 'cyjxz_index',
            component: () =>
                import ('@/pages/cyj.xz/index'),
            meta: { title: '星座运势(陈益嘉)', icon: '05' }
        }]
    },

    {
        path: '/cyj.xzpd',
        component: Layout,
        children: [{
            path: 'index',
            name: 'cyjxzpd_index',
            component: () =>
                import ('@/pages/cyj.xzpd/index'),
            meta: { title: '星座配对(陈益嘉)', icon: '06' }
        }]
    },

    // 404 page must be placed at the end !!!
    { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router